package com.pms.controller;

import java.io.IOException;
import java.util.List;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pms.domain.ProjectSaler;
import com.pms.service.ProjectSalerService;

/** 
* @ClassName: ProjectSalerController 
* @Description:  
* @author ZZW
* @date 2016年12月2日 下午5:56:44 
*  
*/
@Controller
@RequestMapping("/projectsaler")
public class ProjectSalerController {

	@Autowired
	private ProjectSalerService projectSalerService;

	/**
	 * 获得所有对象
	 * @return String
	 * @throws IOException
	 */
	@RequestMapping(value = "/query.pfv",method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public String getProjectSalers() throws IOException {
		List<ProjectSaler> projectSallerList = projectSalerService.getAll() ;
		
		return new String(JSONObject.valueToString(projectSallerList).toString().getBytes(),"utf-8");
	}
	
	/**
	 * 获得单个对象
	 * @param id
	 * @return String
	 * @throws IOException
	 */
	@RequestMapping(value = "/getById.pfv",method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public String getProjectSalerById(@RequestParam(value="id") Integer id) throws IOException {
		ProjectSaler projectSaller = projectSalerService.selectByPrimaryKey(id);
		
		return new String(JSONObject.valueToString(projectSaller).toString().getBytes(),"utf-8");
	}
	
	/**
	 * 插入
	 * @param projectSaler
	 * @throws IOException
	 */
	@RequestMapping(value = "/insert.pfv",method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public void insertProjectSaler(@RequestParam(value="projectSaler") ProjectSaler projectSaler) throws IOException {
		projectSalerService.insertProjectSaler(projectSaler);
	}
	
	/**
	 * 更新
	 * @param projectSaler
	 * @throws IOException
	 */
	@RequestMapping(value = "/update.pfv",method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public void updateProjectSaler(@RequestParam(value="projectSaler") ProjectSaler projectSaler) throws IOException {
		projectSalerService.updateByPrimaryKey(projectSaler);
	}
	
	/**
	 * 删除
	 * @param id
	 * @throws IOException
	 */
	@RequestMapping(value = "/delete.pfv",method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public void deleteProjectSaler(@RequestParam(value="id")Integer id) throws IOException {
		projectSalerService.deleteProjectSaler(id);
	}
	
}
